package com.topscore.uke.mvp.presenters;

import com.topscore.uke.mvp.contractors.UpdateMemberInfoContractor;
import com.topscore.uke.mvp.model.UpdateMemberInfoModel;
import com.topscore.uke.network.request.MemberInfoUpdateRequest;
import com.topscore.uke.network.retrofit.ResultException;

/**
 * Created by 71468 on 2017/10/24.
 */

public class UpdateMemberInfoPresenter implements UpdateMemberInfoContractor,UpdateMemberInfoContractor.Presenter {
    private View mView;
    private Model mModel;
    private MemberInfoUpdateRequest mRequest;

    public UpdateMemberInfoPresenter(View view) {
        this.mView = view;
        mModel = new UpdateMemberInfoModel(new CallBack() {
            @Override
            public void onUpdateSuccess() {
                mView.onUpdateMemberInfoSuccess();
            }

            @Override
            public void onError(int errorCode, String errorMessage) {
                mView.onFail(errorCode,errorMessage);
            }

            @Override
            public void onComplete() {
                mView.onLoadFinished();
            }
        });
        mRequest = new MemberInfoUpdateRequest();
    }

    @Override
    public void updateMemberInfo() {
        mView.onLoading("正在提交");
        mModel.update(mRequest);
    }
}
